草庐IT

Eclipse 快速修复

全部标签

Ruby 动态类。如何修复 "warning: class variable access from toplevel"

我正在尝试编写一个程序,根据从文件中读取的配置动态定义ruby​​类。我知道我可以使用Class.new来做到这一点。这是一个示例程序:x=[1,2,3]Test=Class.newdo@@mylist=xdeffooputs@@mylistendendTest.new.foo当我运行它时,我得到以下输出(使用ruby​​1.9.3p0运行):c:/utils/test.rb:4:warning:classvariableaccessfromtoplevelc:/utils/test.rb:7:warning:classvariableaccessfromtoplevel123Does

ruby - Rails 5 数据库迁移:如何修复 ActiveRecord::ConcurrentMigrationError

之前的rakedb:rollback停滞了。现在,在尝试新的迁移时,我们收到以下错误:rakeaborted!ActiveRecord::ConcurrentMigrationError:Cannotrunmigrationsbecauseanothermigrationprocessiscurrentlyrunning./home/me/.rvm/gems/ruby-2.4.1@global/gems/activerecord-5.1.4/lib/active_record/migration.rb:1315:in`with_advisory_lock'/home/me/.rvm/g

ruby-on-rails - 修复 "ruby installation is missing psych"错误?

我正在运行Rubyruby​​1.9.3p125,但我不断收到此错误,这让我无法在Rails中进行任何类型的开发。Itseemsyourrubyinstallationismissingpsych(forYAMLoutput).Toeliminatethiswarning,pleaseinstalllibyamlandreinstallyourruby.我用Google搜索了一下,似乎尝试了所有方法,但似乎没有任何效果。我真的很想开始一些新项目,但似乎无法绕过这个障碍。非常感谢任何帮助! 最佳答案 我在使用rvm安装ruby​​1.

ruby - 如何修复 Ruby 中挂起的 popen3?

我在使用popen3时遇到意外行为,我想用它来运行类似工具alacmdfile2的命令.下面的示例挂起,因此stdoutdone永远不会达到。使用cat以外的其他工具可能会导致挂起,所以stdindone永远不会达到。我怀疑,我正在遭受缓冲,但我该如何解决这个问题?#!/usr/bin/envrubyrequire'open3'Open3.popen3("cat")do|stdin,stdout,stderr,wait_thr|stdin.puts"foobar"puts"stdindone"stdout.each_line{|line|putsline}puts"stdoutdone

ruby - 如何在 IDE(如 Eclipse)中开发和调试 Chef 说明书和 Recipe ?

我是ruby​​和Chef的新手。我一直在开发Recipe,提交它们,将它们上传到Chef服务器,然后通过角色更改将它们部署到Chef客户端,然后在客户端上运行“chef-client”。这个过程很慢。我如何使用IDE(在我的例子中是Eclipse)开发Recipe并能够调试(设置断点、观察变量等)并运行它们,而无需将它们上传到Chef服务器,然后使用Chef-客户运行?我将Eclipse3.7Indigo与“动态语言工具包-Ruby开发工具3.0.0.v20110424-7Z--E_EkMYXO4k101442”插件一起使用我正在使用10.xChef代码行开发OpscodeChef说

ruby - 如何修复 "Unknown ruby interpreter version (do not know how to handle): RUBY_VERSION."

今天我只想在我的Mac上设置一个jekyll博客,并且已经安装了ruby​​2.3.0,但是当make'$jekyllserve'时,它是错误的。并在终端中显示:错误信息:Unknownrubyinterpreterversion(donotknowhowtohandle):RUBY_VERSION. 最佳答案 看起来像bundleexecjekyllnew将使用以下行创建一个GemfilerubyRUBY_VERSION我相信您会希望将该文件编辑为例如ruby'2.1.1' 关于rub

ruby - 有没有一种快速的方法可以在 Ruby 中找到缺失的结尾?

syntaxerror,unexpected$end,expectingkeyword_end我们都去过那里!假设更改了足够多的代码以至于快速浏览一下gitdiff或类似的东西并不能使它变得明显,是否有一种简单的方法可以找到丢失的end(除了切换到一种基于缩进的语言,如Python)?FWIW,我使用SublimeText2作为我的编辑器。 最佳答案 如果您使用的是Ruby1.9,请在运行您的ruby​​程序时尝试使用-w标志。#t.rbclassExampledefmeth1ifTime.now.hours>12puts"Afte

ruby-on-rails - 如何修复 Mavericks 上 Gemfile 的 libv8 错误?

当我运行bundleinstall时,我得到了Anerroroccurredwhileinstallinglibv8(3.11.8.17),andBundlercannotcontinue.Makesurethat`geminstalllibv8-v'3.11.8.17'`succeedsbeforebundling.Libv8是lunchy和therubyracergems的依赖项。我已经在3.11.8.17上锁定了我的Gemfile.locklibv8gem但是我发现我可以降级到3.3.10.4bundleinstall/update:libv8(therubyracer)inst

ruby-on-rails - 如何修复 Rake 任务中的 "uninitialized constant"

我在做的时候遇到了问题:namespace:xaarondotask:get_rolesdoroles=Xaaron::Role.allputsrolesendtask:get_role,[:name]do|t,args|role=Xaaron::Role.find(args[:name].parameterize)putsroleendend第一个任务可以正常工作。我什至可以添加binding.pry并运行Xaaron::Role并获取有关Roles的信息。但是第二个任务失败了:NameError:uninitializedconstantXaaron::Role我在我的主应用程序中

ruby-on-rails - 如何修复 Rails 中 pg_attribute 表的缓慢隐式查询

在我们的生产环境中,我们注意到Rails应用程序频繁出现峰值(大约每1小时一次)。深入挖掘,这是由于以下查询在单个HTTP请求中累计运行时间超过1.5秒(称为100倍)。SELECTa.attname,format_type(a.atttypid,a.atttypmod),pg_get_expr(d.adbin,d.adrelid),a.attnotnull,a.atttypid,a.atttypmodFROMpg_attributeaLEFTJOINpg_attrdefdONa.attrelid=d.adrelidANDa.attnum=d.adnumWHEREa.attrelid=